import {
  columns,
  tabArr
} from './index.const';
import ElEditable from '@components/el-editable';
import
tabs
from '@components/tabs/index.vue';
export default {
  components: {
    ElEditable,
    tabs
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      rules: {
        rule: [{
          required: true,
          message: '请填写退款原因',
          trigger: 'blur'
        }]
      },
      formData: {
        rule: '',
        price: ''
      },
      tableQuery: {
        supplierName: '',
        originalFactoryName: '',
        orderCode: '',
        orderStatus: null,
        commitDateEnd: '',
        commitDateStart: '',
        productLineCode: ''
      },
      commitDate: ['', ''],
      tableLoading: false,
      tabArr: tabArr,
      columns: columns,
      delDialogVisible: false,
      payload: {},
      // 主列表分页
      currentPage: 1,
      pageSize: 20,
    };
  },
  created() {
    this.getList()
  },
  mounted() {},
  methods: {
    //tab切换
    handletabs(index) {
      if (index === 0) {
        this.tableQuery.orderStatus = null
      } else {
        this.tabArr.forEach((item, i) => {
          if (i === index) {
            this.tableQuery.orderStatus = item.val
          }
        })
      }
      this.queryFormQuery();
    },
    // 重置
    queryFormReset() {
      this.tableQuery = {
        supplierName: '',
        originalFactoryName: '',
        orderCode: '',
        orderStatus: '',
        commitDateEnd: '',
        commitDateStart: '',
        productLineCode: ''
      }
      this.commitDate = ['', '']
      this.currentPage = 1;
      this.getList()
    },
    // 查询
    async queryFormQuery() {
      this.currentPage = 1
      this.getList()
    },
    async getList() {
      this.tableLoading = true
      const query = {
        busModel: 3,
        ...this.tableQuery,
        page: this.currentPage,
        pageSize: this.pageSize,

      };
      query.commitDateStart = this.commitDate[0]
      query.commitDateEnd = this.commitDate[1]
      const data = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({
        query: query
      });
      this.tableLoading = false
      this.payload = data;
    },
    //主列表分页器
    reloadProductData(val) {
      this.currentPage = val.number
      this.pageSize = val.size
      this.getList()
    },
    //导出
    exportEx() {

    },
    //查看
    checkDetail(scope) {
      this.$router.push({
        path: '/financial-management/accounts-receivable-management/detail',
        query: {
          orderId: scope.orderId,
          orderStatus: scope.orderStatus
        }
      });
    },
  }
};